<template>
	<view>
		
		<view class="bgc"></view>
		<view class="info_item">
			<view class="item_ico">
				<image src="../../../../static/img/peo2.png"></image>
			</view>
			<view class="item_context">
				<view class="context_title">{{StudentFindPass.className}}</view>
				<view class="context_info">
					<view class="context_info_name">{{StudentFindPass.name}}</view>
					<view class="context_info_name">{{StudentFindPass.pname}}</view>
				</view>
			</view>
			<view class="item_end">
				<view>2020-01-20</view>
				<view class="Item_bt">
					<view class="Item_bt_no">
						<view class="tx" @click="fail">不通过</view>
					</view>
					<view class="Item_bt_yes">
						<view class="tx" @click="success">通过</view>
					</view>
				</view>
			</view>
		</view>
		<view class="bgc2"></view>
		<uni-popup ref="popupCon" type="dialog">
			<!-- title="通知1" -->
			<uni-popup-dialog type="success" :content="message" :before-close="true" @confirm="dialogConfirm" @close="dialogClose">
			</uni-popup-dialog>
		</uni-popup>
	</view>
</template>

<script>
	
	import {
		checkStudent
	} from '@/api/status/service.js';
	
	import uniPopupMessage from '@/components/uni-popup/uni-popup-message.vue'
	import uniPopupDialog from '@/components/uni-popup/uni-popup-dialog.vue'
	import uniPopupShare from '@/components/uni-popup/uni-popup-share.vue'
	export default {
		components: {
			uniPopupMessage,
			uniPopupDialog,
			uniPopupShare
		},
		props: {

			StudentFindPass: {
				type: Object,
				default: {}
			}
		},
		data(){
			return{
				message:'确定该学生为不通过？',
				flag :true
			}
		},

		methods: {
			fail() {
				this.uncofine()
				console.log("不通过");
			},
			success() {
				this.cofine()
				console.log("通过");
			},
			dialogConfirm(done) {
				console.log('点击确认',parseInt(this.StudentFindPass.stuId), parseInt(this.StudentFindPass.pcId), parseInt(this.StudentFindPass.pId));
				// this.GoApply(parseInt(this.StudentStatusInfo.stuId), parseInt(this.StudentStatusInfo.pcId), parseInt(this.StudentStatusInfo.pId))
				// 需要执行 done 才能关闭对话框
				if(this.flag){
					this.addCheckStudent(parseInt(this.StudentFindPass.stuId), parseInt(this.StudentFindPass.pId), parseInt(this.StudentFindPass.pcId),1);
					this.$emit("pChange")
				}else{
					this.addCheckStudent(parseInt(this.StudentFindPass.stuId), parseInt(this.StudentFindPass.pId), parseInt(this.StudentFindPass.pcId),2);
					this.$emit("pChange")
				}
				done()
			},
			dialogClose(done) {
				console.log('点击取消');
				// 需要执行 done 才能关闭对话框
				done()
			},
			cofine(){
				this.flag = true
				this.message="确定该学生为通过？"
				this.$refs.popupCon.open();
			},
			uncofine(){
				this.flag = false
				this.message="确定该学生为不通过？"
				this.$refs.popupCon.open();
			},
			addCheckStudent(stuId,pId,pcId,status){
				checkStudent(stuId,pId,pcId,status)
				.then(res=>{
					uni.showToast({
						title:"操作成功!",
						duration:2000
					})
				}).catch(res=>{
					uni.showToast({
						title:"操作失败!",
						duration:2000
					})
				})

			}
		}
	}
</script>

<style>
	.bgc {
		background-color: #F5F5F5;
		height: 7rpx;
	}

	.bgc2 {
		background-color: #F5F5F5;
		height: 1rpx;
	}

	.info_item {
		margin: 10rpx;
		display: flex;
		align-items: center;
	}

	.item_ico {
		flex: 1;
	}

	.item_ico image {
		border-radius: 100%;
		width: 120rpx;
		height: 120rpx;
	}

	.item_context {
		flex: 3;
		margin-left: 15rpx;
	}

	.context_title {
		font-size: 16px;
		font-family: .PingFang SC;
		font-weight: 400;
		line-height: 22px;
		color: rgba(78, 78, 78, 1);
		opacity: 1
	}

	.context_info {
		margin-top: 10rpx;
		display: flex;
	}

	.context_info_name {

		font-size: 10px;
		font-family: .PingFang SC;
		font-weight: 400;
		line-height: 20px;
		color: rgba(78, 78, 78, 0.80);

		opacity: 1;
		margin-right: 15rpx;
	}

	.item_end {
		text-align: right;
		flex: 1.5;
		font-size: 12px;
		font-family: .PingFang SC;
		font-weight: 400;
		line-height: 17px;

		opacity: 1;
	}

	.Item_bt {
		margin-top: 15rpx;
		display: flex;

		text-align: right;
		align-items: center;
		vertical-align: center;
	}

	.Item_bt_no {
		width: 55px;
		height: 22px;
		flex: 1;
		align-items: center;
		text-align: center;
		vertical-align: center;
		background-color: #4E4E4E;
		opacity: 0.2;
		display: flex;

	}

	.tx {
		font-size: 12px;
		font-family: .PingFang SC;
		font-weight: 400;
		text-align: center;
		margin: 0 auto;
		vertical-align: center;
		color: rgba(255, 255, 255, 1);
		opacity: 1;
		flex: 1;
		justify-content: center;
	}

	.Item_bt_yes {
		flex: 1;
		width: 55px;
		height: 22px;
		text-align: center;
		align-items: center;
		vertical-align: center;
		margin-left: 15rpx;
		background-color: #357DC5;
		display: flex;
	}
</style>
